#define  _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
int fun(int n)
{
    int i = 0, count = 0;
    while (n)
    {
        if (n % 10 == 1)
            count++;
        n /= 10;
    }
    return count;
}
int main()
{
    int n = 0;
    scanf("%d", &n);
    int i = 0, count = 0;
    for (i = 1; i <= n; i++)
        count += fun(i);
    printf("%d\n", count);
    return 0;
}